
#include <iostream>
using namespace std;
const int MAXM = 12;
char g[4 * MAXM + 5][4 * MAXM + 5];
int mat[MAXM + 5][MAXM + 5];
int m;

void solve()
{
	memset(g, ' ', sizeof(g));
	for (int i = 0; i < 4 * m - 1; ++i)
		g[i][0] = g[i][4 * m + 2] = '*';
	for (int i = 0; i < 4 * m + 3; ++i)
		g[0][i] = g[4 * m - 2][i] = '*';
	int x = -3, y;
	for (int i = 0; i < m; ++i) {
		x += 4, y = -1;
		for (int j = 0; j < m; ++j) {
			y += 4;
			g[x][y] = 'O';
			if (mat[i][j] == -1) {
				g[x - 2][y] = g[x + 2][y] = 'H';
				g[x - 1][y] = g[x + 1][y] = '|';
			}
			if (mat[i][j] == 1) {
				g[x][y - 2] = g[x][y + 2] = 'H';
				g[x][y - 1] = g[x][y + 1] = '-';
			}
		}
	}
	x = -3, y;
	for (int i = 0; i < m; ++i) {
		x += 4, y = -1;
		for (int j = 0; j < m; ++j) {
			y += 4;
			if (mat[i][j] == 0) {
				if (y - 2 > 0 && g[x][y - 2] == ' ') {
					g[x][y - 2] = 'H';
					g[x][y - 1] = '-';
				}
				else {
					g[x][y + 2] = 'H';
					g[x][y + 1] = '-';
				}
				if (x - 2 > 0 && g[x - 2][y] == ' ') {
					g[x - 2][y] = 'H';
					g[x - 1][y] = '|';
				}
				else {
					g[x + 2][y] = 'H';
					g[x + 1][y] = '|';
				}
			}
		}
	}
}

int main()
{
	int cases = 0;
	while (scanf("%d", &m) == 1 && m) {
		for (int i = 0; i < m; ++i)
			for (int j = 0; j < m; ++j)
				scanf("%d", &mat[i][j]);
		printf("Case %d:\n\n", ++cases);
		solve();
		for (int i = 0; i < 4 * m - 1; ++i) {
			for (int j = 0; j < 4 * m + 3; ++j)
				putchar(g[i][j]);
			puts("");
		}
		puts("");
	}
	return 0;
}
